package org.datacoder.geocoding.jurisdiction

/**
 * A state.  Belongs to a country.
 *
 * States have many children.  They store connections to their
 * congressional districts, state representative districts, and
 * state senatorial districts.  They do not store connections to
 * their counties, municipalities, and zip codes, because these
 * are numerous enough that storing them would compromise efficiency.
 */
class State extends Jurisdiction{

    Country country
    SortedSet<CongressionalDistrict> congressionalDistricts
    SortedSet<RepresentativeDistrict> representativeDistricts
    SortedSet<SenatorialDistrict> senatorialDistricts

    static belongsTo = [country:Country]
    static hasMany = [
        congressionalDistricts:CongressionalDistrict,
        representativeDistricts:RepresentativeDistrict,
        senatorialDistricts:SenatorialDistrict
    ]
    public static String retrieveShortName(){
        return "State"
    }
    public String toString(){
        com.vividsolutions.jts.geom.Point point = getMultiPolygon().getCentroid()
        return "State--Name: ${name}; Lat/Long: (${point.getY()}, ${point.getX()})"
    }

}

